package com.fxsh.learn.lambda;

import lombok.Data;

import java.util.List;
import java.util.function.Predicate;

@Data
public class Person {

    public enum Gender {
        Man,Woman
    }

    private String name;
    private int age;
    private Gender gender;

    public Person() {
    }

    public Person(String name, int age, Gender gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public  void printPerson(){
        System.out.println(getName());
    }

//    public static void printPerson(List<Person> persons, CheckPerson checkPerson){
//        for (Person person : persons){
//            if (checkPerson.test(person)){
//                person.printPerson();
//            }
//        }
//    }

    public static void printPerson(List<Person> persons, Predicate<Person> predicate){
        for (Person person : persons){
            if (predicate.test(person)){
                person.printPerson();
            }
        }
    }
}
